FTEX/FTEXS
The .ftex format is a binary format used in conjunction with a variable number of .ftexs files (which is also a binary format) to store a texture in GZ and TPP. The .ftex file contains information on the texture (like the mipmap count, width, height, and depth (for 3D/Volume textures) of the texture) while the .ftexs files contain the raw texture data and information regarding it, such as chunk size, compressed or uncompressed, etc. Together, these files mostly just serve as a wrapper for ZLib-compressed DDS (DirectDraw Surface) files. Usage The Fox Engine uses textures in a completely standard way, but does store them differently. The .ftex file contains information about the texture as a whole and the .ftexs files, which contain the actual image data, albeit ZLib-compressed, have an extension number. Most textures will have a .1.ftexs, .2.ftexs, and a .3.ftexs, and all will have a .ftex. Most of the time, for quick loading, the .ftex and .1.ftexs (the lowest mipmaps are stored in this one) are stored in a .pftxs file in the chunk#.dat files with the rest of the game data, while all four files (.ftex, .1-3.ftexs) are stored in the texture#.dat files. This is not always true - notable exceptions include the Metal Gear Survive (SSD) beta and MGO, which store only the .2.ftexs and .3.ftexs files in the texture#.dat files. Format - Ftex Header * 0x0 - 0x3 (char4): 'FTEX' Format signature. * 0x4 - 0x7 (float): Version number. 2.03 for TPP. * 0x8 - 0x9 (uint16): Pixel format type. * 0xA - 0xB (uint16): Texture height. * 0xC - 0xD (uint16): Texture width. * 0xE - 0xF (uint16): Texture depth. * 0x10 (byte): Mipmap count. * 0x11 (byte): Nrt flag.1 * 0x12 - 0x13 (uint16): Unknown flags.2 * 0x14 - 0x7 (uint32): Unknown (always 1.) * 0x18 - 0x1B (uint32): Unknown (always 0.) * 0x1C - 0x1F (uint32): Texture type.3 * 0x20 (byte): .ftexs file count (not including the .ftex file.) * 0x21 (byte): Unknown (always .ftexs file count - 1.) * 0x22 - 0x2F (byte14): Padding. * 0x30 - 0x37 (StrPathCode64 hash): Hash #1 (unknown use.) * 0x38 - 0x3F (StrPathCode64 hash): Hash #2 (unknown use.) The header is preceded by an array of mip map information blocks - one for each mipmap in the texture. 1What this flag does is unknown but it is 0x02 for all files except for ones suffixed with "_nrt". 2What this flag does is unknown but for most files it is 0x111, for a very small amount of files it is 0x0, and for an extremely (almost no files have this flag) it is 0x11. 3This flag tells the game some information about texture. The flag is 0x01000001 for linear-space textures, 0x01000003 for sRGB-space textures, 0x01000007 for cubemap textures, and 0x01000009 for normal map textures. Mipmap Information * 0x0 - 0x3 (uint32): Offset in the corresponding .#.ftexs file. * 0x4 - 0x7 (uint32): Uncompressed file size. * 0x8 - 0xB (uint32): Compressed file size. * 0xC (byte): Mipmap index (0 is the highest mipmap.) * 0xD (byte): .ftexs file number (3 if in .3.ftexs, 2 if in .2.ftexs, etc.) * 0xE - 0xF (uint16): Chunk count. Format - Ftexs If a given mipmap has a chunk count of 0, then it will use the entire file it references and will contain nothing but ZLib-compressed, raw DDS data of the given DDS format. If the chunk count is greater than one, each mipmap in a file will have an array (table) of chunk information entries, preceded by the data for that mipmap. Each mipmap chunk it its own zlib block; they can't simply all be concatenated and deflated; each needs to be deflated prior to concatenation. Chunk Information * 0x0 - 0x1 (uint16): Compressed chunk size. * 0x2 - 0x3 (uint16): Uncompressed chunk size. * 0x4 - 0x7 (uint32): Data offset.1 1This offset accounts for the size of the chunk information array, and adding the base offset (as specified in the .ftex file via the mipmap information) to the data offset yields the start of the image chunk data. Category:File Formats